<extend name="Public:base"/>
<block name="content">
    <div class="row">
        <div class="col-xs-12">
            <form class="form-horizontal" action="{:U('Activity/add')}" method="post" enctype="multipart/form-data">
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-left">标题： </label>
                    <div class="col-sm-10" style="padding-left: 0">
                        <input id="title" name="title" type="text">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-left">网址： </label>
                    <div class="col-sm-10" style="padding-left: 0">
                        <input type="text" name="content" id="content">
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-left" style="visibility: hidden;">提交：</label>
                    <div class="col-sm-10"  style="padding-left: 0">
                        <input id="mybtn" class="btn btn-primary radius5 btn-sm" type="button" value="提交">
                    </div>
                </div>

            </form>
        </div>
    </div>

</block>
<block name="javascript">
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('edit');
        ue.ready(function () {
            //设置编辑器的内容
            // ue.setContent();
            //获取html内容，返回: <p>hello</p>
            html = ue.getContent();
            //获取纯文本内容，返回: hello
            txt = ue.getContentTxt();
        });
    </script>
    <script>
        $('#mybtn').click(function(){
            var ue = UE.getEditor('edit');
            var html = $('#content').val();
            var title=$('#title').val()
            var status=$('input:radio[name="status"]:checked').val();
            var type=$('#type option:selected') .val();//选中的值
            if(html==''){
                $.jbox.tip("URL不能为空");
                return;
            }
            if(title==''){
                $.jbox.tip("标题不能为空");
                return;
            }
            console.log(status)
            $.ajax({
                url:"{:U('Activity/add')}",
                type:"post",
                data:{
                    content:html,
                    title:title,
                    status:status,
                    type:type
                },
                success:function(data){
                    $.jbox.tip("添加成功！", 'loading');
                    window.setTimeout(function () {window.location.href="{:U('Activity/add')}"; }, 500);
                }
            });


        })
    </script>


</block>

